package com.asen.alibaba.controller;

import com.asen.alibaba.entity.User;
import com.asen.alibaba.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName UserController
 * @Deacription TODO
 * @Author chenxin
 * @Date 2021/3/17 22:08
 *
 * @Api，整个类的注释
 * @ApiOperation，方法上的注释
 * @ApiImplicitParams，参数列表的注释
 * @ApiImplicitParam，每一个参数的注释
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public List<User> list() {
        System.out.println("正在查询所有用户...");
        return userService.list();
    }

    @GetMapping("/save")
    public int save(User user) {
        return userService.save(user);
    }

    @GetMapping("/getById/{id}")
    public User getById(@PathVariable("id") String id) {
        return userService.getById(id);
    }


}
